{extend name="base" /}
{block name="title"}
<title>修改密码</title>
{/block}
{block name="content"}

<fieldset class="layui-elem-field layui-field-title">
    <legend>
        <span class="layui-breadcrumb">
            <a><cite>修改密码</cite></a>
        </span>
    </legend>
</fieldset>
<!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>方框风格的表单集合</legend>
</fieldset>-->

<form class="layui-form layui-form-pane" action="" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require">*</i>旧密码</label>

        <div class="layui-input-inline">
            <input type="password" name="old_password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">请填写5到20位密码</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require">*</i>新密码</label>

        <div class="layui-input-inline">
            <input type="password" name="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">请填写5到20位密码</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="require">*</i>确认密码</label>

        <div class="layui-input-inline">
            <input type="password" name="repassword" lay-verify="repass" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">请填写5到20位密码</div>
    </div>
    <div class="layui-form-item" style="margin-left: 50px;">
        <button class="layui-btn" lay-submit="" lay-filter="sub">提交</button>
        <button type="reset" class="layui-btn layui-btn-danger btn-reset">重置</button>
    </div>
</form>
{/block}
{block name="js"}
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','element'], function () {
        var form = layui.form, layer = layui.layer, layedit = layui.layedit, laydate = layui.laydate,element = layui.element,$ = layui.jquery;

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            repass: function (value) {
                if (value.length <= 0) {
                    return '密码不能为空';
                }
                var new_pass = $('input[name=password]').val();
                if (new_pass != value) {
                    return '确认密码和新密码不一致';
                }
            }
            , pass: [/(.+){5,20}$/, '密码必须5到20位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(sub)', function (data) {
            return true;
        });

    });
</script>
{/block}